<template>
  <div class="content">
    <div class='father'>
      <p style='text-align: left;'> <img :src="'../../static/image/gold'+id+'.png'" alt=""></p>
      <div class='son'>
        <div ref='sunzii' :class='{"sunzi gold":id=="2","sunzi ying":id=="3","sunzi tong":id=="4",}'>
          <p>当前{{progress}}%</p>
        </div>
      </div>
      <p>当前：{{Math.floor(progress*100)}}/10000</p>
    </div>
    <div>
        <p style='text-align: left;'> <img :src="'../../static/image/gold'+id+'.png'" alt=""></p>
        <img src="" alt="">
    </div>
  </div>
</template>

<script>
import $ from "jquery";
import { setTimeout, setInterval, clearInterval } from "timers";
export default {
  data() {
    return {
      progress: 0,
      id: u.getStore("istype")
    };
  },
  created() {
    let time = setInterval(() => {
      if (u.flag) {
        clearInterval(time);
        u.getBi({ activityId: u.getStore("activity") }, data => {
          if (data && data[0].code == "200") {
            let progress = data[0].data;
            this.$refs.sunzii.style.width = progress / 1.061 + "%";
            let timmer = setInterval(() => {
              this.progress++;
              if (this.progress >= progress) {
                this.progress = progress;
                if (this.progress == 100) {
                  this.$parent.pop_index = false;
                }
                clearInterval(timmer);
              }
            }, 30);
          }
        });
      }
    }, 10);
  },
  methods: {
    bar() {}
  },

  mounted() {
    setTimeout(() => {
      this.bar();
    }, 1000);
  }
};
</script>

<style scoped lang='less'>
// .content {
//   height: 100vh;
//   width: 100vw;
//   // background: url(../../static/image/ginsengbg2.png) no-repeat center;
// }
.father {
  height: 100px;
  width: 520px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 12px;
  box-sizing: border-box;
  .son {
    width: 100%;
    height: 70px;
    background: url(../../static/image/barbg.png) no-repeat center;
    .sunzi {
      position: relative;
      left: 14px;
      height: 100%;
      height: 28px;
      width: 0;
      transition: width 2s;
      line-height: 70px;
      // text-align: center;
      text-shadow: -2px 1px 1px rgba(34, 113, 42, 0.75),
        2px -1px 1px rgba(34, 113, 42, 0.75);
      color: white;
      white-space: nowrap;
      box-sizing: border-box;
      border-radius: 12px;
      position: relative;
      top: 21px;
      p {
        width: 520px;
        box-sizing: border-box;
        padding-left: 200px;
        text-align: left;
        position: relative;
        top: -19px;
      }
    }
    .gold {
      background: url(../../static/image/goldProgress.png) no-repeat center;
      background-size: 160% 200%;
    }
    .ying {
      background: url(../../static/image/yingProgress.png) no-repeat center;
      background-size: 160% 200%;
      text-shadow: 1px 1px 1px rgba(197, 197, 197, 0.75),
        1px -1px 1px rgba(197, 197, 197, 0.75);
    }
    .tong {
      background: url(../../static/image/tongProgress.png) no-repeat center;
      background-size: 160% 200%;
      text-shadow: 1px 1px 1px rgba(255, 137, 68, 0.75),
        1px -1px 1px rgba(255, 137, 68, 0.75);
    }
    // .goldx{
    //   text-align: left;
    // }
  }

  p {
    font-size: 16px;
    color: white;
    padding-left: 10px;
    text-shadow: -2px 1px 1px rgba(137, 64, 0, 0.75),
      2px -1px 1px rgba(137, 64, 0, 0.75);
    text-align: center;
  }
}
</style>
